var t = getApp(),
	a = t.requirejs("core"),
	i = t.requirejs("foxui"),
	r = t.requirejs("wxParse/wxParse");
Page({
	data: {
		beforeColor: "rbga(0,0,0,.5)",
		afterColor: "white",
		adveradmin: !0,
		current: 0,
		indicatorDots: !0,
		autoplay: !0,
		interval: 5e3,
		duration: 500,
		circular: !0,
		cate: 1,
		detail: {},
		images: [],
		page: 1,
		loading: false,
		loaded: false,
		list: [],
		comment: false,
		bannerImg: [],
		data: {}
	},

	onLoad: function (s) {
		this.setData({
			options: s,
		})
		a.get("syt.merch.xiang_detail", {
			id: s.id
		}, res => {
			console.clear();
			var content = res.list.content ? `<div>${res.list.content}</div>` : "";
			r.wxParse("introduce", "html", content, this, 0);
			wx.setNavigationBarTitle({
				title: res.list.name
			});
			console.log(res);
			this.setData({
				bannerImg: res.list.thumbs,
				data: res.list
			})
		})
		// , this.getShow(), this.getList();
	},
	onShow: function () {
		var that = this;
		t.getCache("isIpx") ? that.setData({
			isIpx: !0,
			iphonexnavbar: "fui-iphonex-navbar",
			paddingb: "padding-b"
		}) : that.setData({
			isIpx: !1,
			iphonexnavbar: "",
			paddingb: ""
		})
		// 模拟部分数据
		that.setData({
			show: !0
		})

	},
	getList: function () {
		var t = this;
		t.setData({
			loading: true
		}), a.get("member.address.get_list", {
			page: t.data.page,
			pid: t.data.options.id
		}, function (e) {
			console.log(e);
			var i = {
				loading: false,
				total: e.total,
				pagesize: e.pagesize,
				show: !0
			};
			e.list.length > 0 && (i.page = t.data.page + 1, i.list = t.data.list.concat(e.list),
				e.list.length < e.pagesize && (i.loaded = true)), t.setData(i);
		});
	},
	cate: function (p) {
		var cate = p.currentTarget.dataset.type;
		this.setData({
			list: [],
			page: 1,
			cate: cate,
			loaded: false,
		}), this.getList();
	},
	make: function (p) {
		var id = p.target.dataset.id,
			shopid = p.currentTarget.dataset.shopid;
		wx.redirectTo({
			// url: "/pages/member/address/index?id=" + id
			url: "/project/yuyue?id=" + id + `&shopid=${shopid}`
		})
	},
	onChange: function (t) {
		this.setData({
			content: t.detail.value
		})
	},
	onReachBottom: function () {
		if (this.data.cate == 2)
			this.data.loaded || this.data.list.length == this.data.total || this.getList();
	},
	onPullDownRefresh: function () {
		wx.stopPullDownRefresh();
	},
	onShareAppMessage(p) {
		let that = this;
		var id = p.target.dataset.id;
		img = p.target.dataset.img,
			title = p.target.dataset.title;
		return {
			title: title,
			path: "/project/detail/index" + id,
			imageUrl: img,
			success(res) {
				if (res.errMsg == "shareAppMessage:ok") {
					wx.showToast({
						title: "转发成功",
						icon: "none"
					})
				}
			}
		}
	},
});